<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2021/5/31
  Time: 17:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@include file="/common/common.jsp" %>
<html>
<head>
    <title>Title</title>
    <script>
        function chaxun() {
            $.ajax({
                url: "<%=path%>/user/selectuname",
                data: $("#loginForm").serialize(),
                type: "post",
                dataType: "json",
                async: true,
                success: function (result) {
                    if (result == true) {
                        alert("可以");
                    } else {
                        alert("有该账号");

                    }

                },
                error: function (result) {
                    console.log(result);
                    alert("网络异常请刷新");

                }


            })

        }

        function loginingo() {
            $.ajax({
                url: "<%=path%>/user/insertInfo",
                data: $("#loginForm").serialize(),
                type: "post",
                dataType: "json",
                async: true,
                success: function (result) {
                    if (result == true) {
                        alert("注册成功");
                        location.href="<%=path%>/index.jsp";
                    }else if(result==false){
                        alert("注册失败");
                    }
                },
                error: function (result) {
                    alert("网络异常");
                    console.log(result);
                }

            })
        }
    </script>
</head>
<body>
<div class="container-fluid">
    <div class="panel panel-primary" style="width:400px">
        <div class="panel-heading">
            <h1>注册</h1>
        </div>
        <div class="panel-body">
            <form id="loginForm">
                <div class="form-group">
                    <label for="uname">账号</label>
                    <input type="text" class="form-control" name="uname" id="uname" placeholder="请输入账号" onblur="chaxun()">
                    <div id="tips"></div>
                </div>
                <div class="form-group">
                    <label for="password">密码</label>
                    <input type="password" class="form-control" name="password" id="password">
                </div>
                <input type="button" class="btn btn-success btn-lg" value="注册" onclick="loginingo()">
            </form>
        </div>
    </div>
</div>

</body>
</html>
